/**
 * Created with Intellij JDEA
 * Description:
 * User:
 * Date:2022-05-23
 * Time:11:08
 */
public class 调整数组顺序使奇数位于偶数前面 {
    public int[] exchange(int[] nums) {
        int i = 0;
        int j = nums.length - 1;
        while(i < j) {
            while(i < j && nums[i] % 2 != 0) {
                i++;
            }
            while(i < j && nums[j] % 2 == 0) {
                j--;
            }
            int tmp = nums[i];
            nums[i] = nums[j];
            nums[j] = tmp;
        }
        return nums;
    }
}
